<?php

/*
 * This file is part of PHP CS Fixer.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *     Dariusz Rumiński <dariusz.ruminski@gmail.com>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace app\common\lib;

class Status
{
    protected $status = [
        //cms_栏目
        'cms_category'     => [
            'status'    => [
                '0' => '不启用',
                '1' => '启用',
            ],
            'is_show'   => [
                '0' => '显示',
                '1' => '不显示',
            ],
            'is_delete' => [
                '0' => '不删除',
                '1' => '删除',
            ],
        ],
        //cms_广告
        'cms_poster'       => [
            'status' => [
                '0' => '不启用',
                '1' => '启用',
            ],
        ],
        //cms_广告位
        'cms_poster_space' => [
            'status' => [
                '0' => '不启用',
                '1' => '启用',
            ],
        ],
    ];

    //退款单前后单状态对应
    const RETURN_ORDER_STATUS = [
        0  => 0,
        1  => 1,
        2  => 2,
        3  => 3,
        -1 => -1,
        -2 => -1,
        -3 => -2,
    ];

    const RETURN_ORDER_STATE_MSG = [
        -3 => '取消售后',
        -2 => '财务审核拒绝',
        -1 => '平台审核拒绝',
        0  => '用户申请',
        1  => '平台审核通过',
        2  => '平台已收货',
        3  => '平台已退款',
    ];

    public function get_status($table = '', $field = '', $value = '')
    {
        if ('' === $table) {
            return $this->status;
        }
        if ('' === $field) {
            return $this->status[$table] ?: false;
        }
        if ('' !== $value) {
            return isset($this->status[$table][$field][$value]) ? $this->status[$table][$field][$value] : $value;
        }

        return $value;
    }
}
